package com.chen.state;

import java.text.SimpleDateFormat;
import java.util.Date;

// 模拟当前时间
public class TestSleep2 {

    public static void main(String[] args) throws InterruptedException {
        // 当前系统时间
        Date startTime = new Date(System.currentTimeMillis());

        while (true) {
            Thread.sleep(1000);
            System.out.println(new SimpleDateFormat( "HH:mm:ss").format(startTime));
            // 更新当前时间
            startTime = new Date(System.currentTimeMillis());
        }

    }

}
